package com.yishu.user.controller;

import com.yishu.user.service.UserService;
import com.ys.commons.model.JsonResponse;
import com.ys.commons.model.dto.UserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * 用户相关接口
 *
 * @author zengchao
 * @date 2021-07-03 09:37:31
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @Value("${server.port}")
    private Integer serverPort;

    /**
     * 根据用户ID获取用户信息
     * @param id 用户ID
     * @return
     */
    @GetMapping()
    public JsonResponse<UserDto> getUser(@RequestParam("id")Integer id){
        UserDto user = userService.getUser(id);
        JsonResponse<UserDto> response = JsonResponse.ok(user);
        response.setMsg(response.getMsg()+":"+serverPort);
        return response;
    }

}
